cmake_minimum_required(VERSION 3.5)
project(gui_client)


find_package (ament_cmake_auto REQUIRED) 

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(Boost REQUIRED)
find_package(example_interfaces REQUIRED)


#ament_auto_add_library ( client_lib SHARED 
#    src/gui_client.cpp 
#    include/GUI_client/gui_client.h)

# 添加源文件，生成库
add_library(gui_client SHARED 
    src/gui_client.cpp 
    include/gui_client/gui_client.h)

# 用于代替传统的target_link_libraries
ament_target_dependencies(gui_client
        PUBLIC
        rclcpp
        ${Boost_LIBRARIES}
        std_msgs
        )

# 添加头文件地址
target_include_directories(gui_client PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:include/>
        )


# 为了使下游文件可以访问
ament_export_targets(gui_client HAS_LIBRARY_TARGET)
ament_export_dependencies(
        rclcpp
        std_msgs
        ${Boost_LIBRARIES}
        example_interfaces
)


# 注册 导出头文件
install(
        DIRECTORY include/
        DESTINATION include
)

# 注册 导出库文件
install(
        TARGETS gui_client
        EXPORT gui_client
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
        RUNTIME DESTINATION bin
        INCLUDES DESTINATION include
)


add_executable(client_test
        src/client_test.cpp
        )

ament_target_dependencies(client_test
        rclcpp
        std_msgs
        ${Boost_LIBRARIES}
        example_interfaces
        )

install(TARGETS client_test
        DESTINATION lib/${PROJECT_NAME})
ament_package()
